<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:content identifier="information" ignore="true" />
<atleap:constants className="org.apache.struts.Globals" var="LOCALE_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="GRID_PAGE_SIZE" />
<atleap:globalProperty name="${pageScope.GRID_PAGE_SIZE}" defaultValue="10" type="integer" var="pageSize" />

<atleap:isUserInRole roles="questionnaire-filledItem-view" var="canView" />
<atleap:isUserInRole roles="questionnaire-filledItem-delete" var="canDelete" />

<c:set var="infoCells" value="2" />
<c:set var="constantButtonCells" value="0" />
<c:set var="additionalCells" value="0" />
<c:if test="${canView}">
	<c:set var="additionalCells" value="${additionalCells+1}" />
</c:if>
<c:if test="${canDelete}">
	<c:set var="additionalCells" value="${additionalCells+1}" />
</c:if>

<atleap:grid name="filledQuestionnaireGrid" pageSize="${pageSize}">
    <atleap:queryParameter name="localeIdentifier" value="${sessionScope[pageScope.LOCALE_KEY].language}" />
	<atleap:messages property="filledQuestionnaireNotFound" />
    <table border="0" cellpadding="0" cellspacing="0" class="grid">
        <thead>
            <tr>
                <th nowrap="nowrap">
                    <atleap:column fieldName="title.simpleValue" fieldKey="questionnaire.filledQuestionnaire.form.title">
                        <atleap:sort>
                            <atleap:message key="${fieldKey}" />
                            <atleap:sortAsc>
                                <img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/grid/ascSort.gif" />"  />
                            </atleap:sortAsc>
                            <atleap:sortDesc>
                                <img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/grid/descSort.gif" />"  />
                            </atleap:sortDesc>
                        </atleap:sort>
						<atleap:stringFilter>
							<atleap:filterEnabled>
								<img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/grid/filterEnabled.gif" />"  />
							</atleap:filterEnabled>
							<atleap:filterDisabled>
								<img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/grid/filterDisabled.gif" />"  />
							</atleap:filterDisabled>
						 </atleap:stringFilter>
                    </atleap:column>
                </th>
                <th nowrap="nowrap">
                    <atleap:column fieldName="fq.date" fieldKey="questionnaire.filledQuestionnaire.form.date">
                        <atleap:sort>
                            <atleap:message key="${fieldKey}" />
                            <atleap:sortAsc>
                                <img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/grid/ascSort.gif" />"  />
                            </atleap:sortAsc>
                            <atleap:sortDesc>
                                <img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/grid/descSort.gif" />"  />
                            </atleap:sortDesc>
                        </atleap:sort>
						<atleap:dateFilter>
							<atleap:filterEnabled>
								<img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/grid/filterEnabled.gif" />"  />
							</atleap:filterEnabled>
							<atleap:filterDisabled>
								<img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/grid/filterDisabled.gif" />"  />
							</atleap:filterDisabled>
						 </atleap:dateFilter>
                    </atleap:column>
                </th>
                <c:if test="${constantButtonCells + additionalCells > 0}">
                    <th colspan="${constantButtonCells + additionalCells}">
                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/spacer.gif" />" border="0"  />
                    </th>
                </c:if>
            </tr>
        </thead>
        <tbody>
            <atleap:contextMenu var="menuId">
                <atleap:rowsIterator beanId="questionnaireManager" method="listFilledQuestionnaires" var="filledQuestionnaire" oddClass="oddRow" evenClass="evenRow">
                    <atleap:itemSet>
                        <c:set var="confirmDeleteScript" value="return confirmDelete();" />
                        <atleap:rewriteUrl action="questionnaire/filledQuestionnaire/view" var="defaultUrl">
                            <atleap:param name="id" value="${filledQuestionnaire.id}" />
                        </atleap:rewriteUrl>
                        <c:set var="onTrClickCode" value="" />
                        <c:set var="tdClass" value="defaultCursorCell" />
                        <c:if test="${canView}">
                            <c:set var="onTrClickCode" value="dispatchGridTrClick(event, this, &#039;${defaultUrl}&#039;);" />
                            <c:set var="tdClass" value="pointerCursorCell" />
                        </c:if>
                        <tr class="${rowClass}" oncontextmenu="return showContextMenu(${menuId}, event, ${indexId});" onclick="${onTrClickCode}">
                            <td class="${tdClass}">
                                <atleap:fieldValue valueMap="${filledQuestionnaire.questionnaire.title}" />
                            </td>
                            <td class="${tdClass}">
                                <atleap:formatDate value="${filledQuestionnaire.date}" type="datetime" />
                            </td>
                            <atleap:item includeInContextMenu="${canView}" includeInPage="${canView}">
                                <td align="center" width="20" height="20" valign="middle" class="defaultCursorCell">
                                    <atleap:itemEnabled>
                                        <atleap:message key="core.commons.buttons.view" var="viewMsg"/>
                                        <atleap:itemLink action="questionnaire/filledQuestionnaire/view" title="${viewMsg}">
                                            <atleap:param name="id" value="${filledQuestionnaire.id}" />
                                                <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/view.gif" />" border="0" title="${viewMsg}" alt="${viewMsg}" align="absmiddle" />
                                                <atleap:itemLabel>
                                                    ${viewMsg}
                                                </atleap:itemLabel>
                                        </atleap:itemLink>
                                    </atleap:itemEnabled>
                                </td>
                            </atleap:item>
                            <atleap:item includeInContextMenu="${canDelete}" includeInPage="${canDelete}">
                                <td align="center" width="20" height="20" valign="middle" class="defaultCursorCell">
                                    <atleap:itemEnabled>
                                        <atleap:message key="core.commons.buttons.delete" var="deleteTitle"/>
                                        <atleap:itemLink action="questionnaire/filledQuestionnaire/delete" transaction="true" confirmExpression="confirmDelete();" title="${deleteTitle}">
                                            <atleap:param name="id" value="${filledQuestionnaire.id}" />
                                                <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/delete.gif" />" border="0" title="${deleteTitle}" alt="${deleteTitle}" align="absmiddle" />
                                                <atleap:itemLabel>
                                                    ${deleteTitle}
                                                </atleap:itemLabel>
                                        </atleap:itemLink>
                                    </atleap:itemEnabled>
                                </td>
                            </atleap:item>
                        </tr>
                    </atleap:itemSet>
                </atleap:rowsIterator>
            </atleap:contextMenu>
            <atleap:noRows>
                <tr>
                    <td class="tfoot"  colspan="${infoCells + constantButtonCells + additionalCells}" align="center">
                        <em><atleap:message key="core.commons.nothingToShow"/></em>
                    </td>
                </tr>
            </atleap:noRows>
        </tbody>
        <tfoot>
            <tr>
                <atleap:pager pageCount="10">
                    <td  colspan="${infoCells + constantButtonCells + additionalCells}" align="center">
                        <atleap:message key="core.grid.pager.title" />&nbsp;
                        <atleap:firstPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/first.gif" />" border="0" alt="<atleap:message key="core.grid.pager.first"/>" title="<atleap:message key="core.grid.pager.first"/>" /></atleap:firstPage>
                        <atleap:prevPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/prev.gif" />" border="0" alt="<atleap:message key="core.grid.pager.prev"/>" title="<atleap:message key="core.grid.pager.prev"/>" /></atleap:prevPage>
                        <atleap:pagesIterator>
                            <atleap:page>${pageNumber}&nbsp;</atleap:page>
                            <atleap:currentPage><b>${pageNumber}</b>&nbsp;</atleap:currentPage>
                        </atleap:pagesIterator>
                        <atleap:nextPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/next.gif" />" border="0" alt="<atleap:message key="core.grid.pager.next"/>" title="<atleap:message key="core.grid.pager.next"/>" /></atleap:nextPage>
                        <atleap:lastPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/last.gif" />" border="0" alt="<atleap:message key="core.grid.pager.last"/>" title="<atleap:message key="core.grid.pager.last"/>" /></atleap:lastPage>
                    </td>
                </atleap:pager>
            </tr>
        </tfoot>
    </table>
</atleap:grid>
